//
//  ExclusiveMoreViewController.m
//  Music
//
//  Created by dllo on 16/6/8.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ExclusiveMoreViewController.h"
#import "LHQExclusiveTableViewCell.h"
#import "ExclusiveModel.h"
#import "ExclusiveDetailViewController.h"
@interface ExclusiveMoreViewController ()<UITableViewDelegate ,UITableViewDataSource>
@property(nonatomic,retain)UITableView  *tableView;
@property(nonatomic,retain)NSMutableArray  *dataSource;
@end

@implementation ExclusiveMoreViewController
-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.dataSource = [NSMutableArray  array];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor  whiteColor];
    self.navigationItem.title = @"音乐专题";
    self.navigationController.navigationBar.barStyle = 1;
    self.navigationController.navigationBar.tintColor = [UIColor  whiteColor];
    [self  getDataSource];
}
-(void)getDataSource
{
    NSString  *url = @"http://api.dongting.com/misc/musiczone/new?app=ttpod&v=v9.0.2.2016052421&user_id=0&mid=iPhone8%2C2&f=f320&s=s310&imsi=&hid=&splus=9.3.2&active=1&net=2&openudid=714e0317ebb947064241a6abe30a1fc639430b24&idfa=F8C6B2DF-27B0-4A7B-9E83-A86B4F61321F&utdid=Vw2RqCpjWHwDAAGyCA35RHh7&alf=(null)&bundle_id=com.ttpod.music&latitude=38.88327772352431&longtitude=121.5445855034722&access_token=(null)&vc=9000200";
    [MyTools  getNetWithUrl:url body:nil header:nil response:LHQJSON success:^(id result) {
        NSDictionary  *dic = (NSDictionary *)result;
        NSMutableArray  *temp = dic[@"data"];
        for (NSDictionary  *dict in temp) {
            ExclusiveModel  *model = [[ExclusiveModel  alloc]initWithDic:dict];
            [self.dataSource  addObject:model];
        }
        [self  tableViewSubView];
        [self.tableView  reloadData];
        
        
    } failure:^(NSError *error) {
        
    }];
    
}
-(void)tableViewSubView
{
    self.tableView = [[UITableView  alloc]initWithFrame:CGRectMake(0, 0, Screenwidth, Screenheight-64-49) style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    [self.tableView  registerClass:[LHQExclusiveTableViewCell  class] forCellReuseIdentifier:@"Exclusive"];
    [self.view  addSubview:_tableView];

}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataSource.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LHQExclusiveTableViewCell   *cell = [tableView  dequeueReusableCellWithIdentifier:@"Exclusive"];
    cell.model = self.dataSource[indexPath.row];
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 200;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    ExclusiveDetailViewController   *detail = [[ExclusiveDetailViewController   alloc] init];
    ExclusiveModel  *model  = self.dataSource[indexPath.row];
    detail.url = model.actionUrl;
    
    [self.navigationController  pushViewController:detail animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
